package com.gf.service.impl;

import com.gf.bean.Menu;
import com.gf.bean.Shop;
import com.gf.dao.MenuMapper;
import com.gf.dao.ShopMapper;
import com.gf.service.MenuService;
import com.gf.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;
import java.util.List;

public class MenuServiceImpl implements MenuService {

    @Override
    public List<Menu> selectmenubyshopid(int shop_id) {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        List<Menu> menus = sqlSession.getMapper(MenuMapper.class).selectmenubyshopid(shop_id);
        MybatisUtils.closesqlSession(sqlSession);

        return menus;
    }

    @Override
    public List<Menu> selectmenubydishid(ArrayList<Integer> dishs) {

            SqlSession sqlSession = MybatisUtils.getsqlSession();
            List<Menu> menus = sqlSession.getMapper(MenuMapper.class).selectcart(dishs);
            MybatisUtils.closesqlSession(sqlSession);

            return menus;

    }

    @Override
    public List<Menu> selectthreemenu() {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        List<Menu> menus = sqlSession.getMapper(MenuMapper.class).selectthreemenu();
        MybatisUtils.closesqlSession(sqlSession);
        return menus;
    }

    @Override
    public int insert(Menu record) {
        SqlSession sqlSession = MybatisUtils.getsqlSession();
        int insert = sqlSession.getMapper(MenuMapper.class).insert(record);
        MybatisUtils.closesqlSession(sqlSession);
        return insert;
    }

}

